#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include "gpio.h"

void GpioInit() {
	GPIO_InitTypeDef GPIO_InitStructure;
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
    GPIO_InitStructure.GPIO_Pin = GpioPin_FpgaSpiCs0 | GpioPin_FpgaSpiCs1 | GpioPin_I2cSwitchCtrl;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    GPIO_SetBits(GpioPort_FpgaSpiCs0, GpioPin_FpgaSpiCs0 | GpioPin_FpgaSpiCs1);

}

void GpioSetValue(const GpioId *gpioId, Bool isHigh) {
    if (isHigh) {
        GPIO_SetBits(gpioId->gpioPort, gpioId->gpioPin);
    }
    else {
        GPIO_ResetBits(gpioId->gpioPort, gpioId->gpioPin);
    }
}

